/********************************************************************

Class: GlBase::GlEvent - Basic OpenGL event

Write Date: 2011/03/22
Author: Deng Nianchen
>>>> Implements general function of OpenGL event.

*********************************************************************/
#ifndef GL_EVENT_HPP
#define GL_EVENT_HPP
#include "OOPGl_BaseGlobal.hpp"
#include "GlPoint.hpp"

_GLBASE_BEGIN

/**************************************************************************************************
 * <summary>  Defines an alias representing state of OpenGL mouse button. </summary>
 *
 * <remarks>  Deng Nianchen, 2011/3/22. </remarks>
 **************************************************************************************************/

typedef glm::bvec3 GlMouseButtonState;

class GlEvent
{
public:

	enum EventType
	{
		MOUSE_DOWN, MOUSE_UP, MOUSE_MOVE,
		KEY_DOWN
	};

private:

	EventType _type;
	GlPoint _mousePosition;
	GlMouseButtonState _mouseButtonState;
	int _key;

public:

	//************************************
	// Method:    getType
	// Returns:   GlEvent::EventType
	// Get the type of this event
	//************************************
	EventType getType () const { return _type; }

	//************************************
	// Method:    getMousePosition
	// Returns:   int * - An array which contains two elements: x and y
	// Get current mouse position
	//************************************
	GlPoint getMousePosition () const
	{
		return _mousePosition;
	}

	//************************************
	// FullName:  GlEvent::getMouseButtonState
	// Returns:   bool * - An array which contains three elements
	// Get current state of the three buttons of mouse
	// (true means down, false means up)
	//************************************
	GlMouseButtonState getMouseButtonState () const
	{
		return _mouseButtonState;
	}

	//************************************
	// FullName:  GlEvent::getKey
	// Returns:   int
	// Get the key which raise the event (negative value means it's a special
	// key and its absolute value is the corresponding special key value
	// defined by GLUT)
	//************************************
	int getKey () const { return _key; }

	/************************************************************************/
	/* Setter functions which are called by the framework                   */
	/************************************************************************/

	void setType (EventType eventType) { _type = eventType; }

	void setMousePosition (int x, int y)
	{
		_mousePosition = GlPoint (x, y);
	}

	void setMousePosition (const GlPoint & mousePosition)
	{
		_mousePosition = mousePosition;
	}

	void setMouseButtonState (const GlMouseButtonState & curState)
	{
		_mouseButtonState = curState;
	}

	void setKey (int key) { _key = key; }
};

_GLBASE_END

#endif